<template>
  <div>
      <h1>设定</h1>
      <ul>
      <li v-for="task in tasktimes">
        <div>{{task.taskname}}</div>
        <el-time-select
        v-model=task.time
        :picker-options="{
            start: '00:00',
            step: '00:01',
            end: '23:59'
        }"
        placeholder="选择时间">
       </el-time-select>
     <el-button type="primary" @click="setting(task)">设定</el-button>
          </li>
      </ul>
  <!--     定时任务:
     <el-time-select
        v-model="value2"
        :picker-options="{
            start: '00:00',
            step: '00:01',
            end: '23:59'
        }"
        placeholder="选择时间">
     </el-time-select>
      <el-button type="primary">设定</el-button> -->
  </div>
</template>
<style lang="stylus" scoped>
h1{
    margin-left 60px
}
ul{
    list-style-type:none
}
ul li{
    margin-top:10px
}
</style>

<script>
import {getDataSyncList, setDatasyncTime} from '../api/index'
export default {
  name: 'hello',
  data () {
    return {
      tasktimes: []
    }
  },
  created: function () {
    console.log('created')
    this.init()
  },
  methods: {
    setting: function (task) {
      console.log(task.id)
      console.log(task.time)
      var params = {id: task.id, time: task.time}
      console.log(params)
      setDatasyncTime(task).then(res => {
        console.log(res)
      })
    },
    init: function () {
      getDataSyncList(getDataSyncList).then(res => {
        if (res.code === 200) {
          console.log(res.data)
          this.tasktimes = res.data
        }
      })
    }
  }
}
</script>

